import { View, ITouchEvent } from "@tarojs/components";
import "./index.scss";
import IconFont from "../../../components/iconfont";
import { STATUS } from "../../../configProvider";

export interface HistoryCardProps {
  name: string,
  startTime: string,
  endTime: string,
  weekday: string,
  teacher: string,
  onClick?: (event: ITouchEvent) => void,
  status: STATUS,
  checkDate: string,
  attended?: boolean,
  leaved?: boolean,
  totalNum: number,
  attendNum: number,
  leaveNum: number
}
const HistoryCard: React.FC<HistoryCardProps> = ({ name, teacher, startTime, endTime, weekday, checkDate, onClick, status, attended, leaved, totalNum, attendNum, leaveNum }) => {
  return (<View className="course-card" onClick={onClick}>
    <View className="course-card-title">{name}</View>
    <View className="course-card-teacher">{teacher}</View>
    <View className="course-card-weekday">{weekday}</View>
    <View className="course-card-duration">{startTime}~{endTime}</View>
    <View className="course-card-date">{checkDate}</View>
    <View className="course-card-action" >
      {status === STATUS.STUDENT
        ? (attended
          ? <View className="course-card-action-tips-1">出勤</View>
          : leaved
            ? <View className="course-card-action-tips-7">请假</View>
            : <View className="course-card-action-tips-2">缺席</View>)
        : <>
          <View className="course-card-action-tips-6">总共{totalNum}人</View>
          <View className="course-card-action-tips-3">出勤{attendNum}人</View>
          <View className="course-card-action-tips-4">缺席{totalNum - attendNum - leaveNum}人</View>
          <View className="course-card-action-tips-5">请假{leaveNum}人</View>
        </>
      }
    </View>
  </View>)
}
export default HistoryCard;
